import lombok.Data;

@Data
public class Vehicle implements Consumer{
private double maximumCapacity;
private double currentCapacity;
private double reserve;

Vehicle(double reserve, double maximumCapacity){
    this.reserve=reserve;
    this.maximumCapacity=maximumCapacity;
    this.currentCapacity=0.0;
}
 public double fill(double nLitres) {
     //verify if tank can handle
     if((currentCapacity+nLitres)>maximumCapacity) return 0;
   
     //fill
     currentCapacity = currentCapacity + nLitres;
     return nLitres;     
 }
 public double fillAll() {
     //if already filled, return zero
     if(maximumCapacity<=currentCapacity) return 0;
     
     double nLitresToFill= maximumCapacity - currentCapacity;
     currentCapacity=maximumCapacity;
    return nLitresToFill;     
 }

public void consume(double gasLitres) {  
    //verify if has enough Fuel
    if(currentCapacity>=gasLitres) currentCapacity = currentCapacity - gasLitres;
    //if it has no Fuel, do nothing
    ;
}

public boolean isOnReserve() {
    return currentCapacity<reserve;
}
}
